{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "array = [5, 7, 3, 8, 9, 23, 6]\n",
    "target = 100\n",
    "tmp_dict = {}\n",
    "flag = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "没有找到\n"
     ]
    }
   ],
   "source": [
    "for i,num in enumerate(array):\n",
    "    other = target - num\n",
    "    if tmp_dict.get(other) is not None:\n",
    "        print(tmp_dict[other], '\\t', i)\n",
    "        flag = True\n",
    "        break\n",
    "    else:\n",
    "        tmp_dict[num] = i\n",
    "\n",
    "if not flag:\n",
    "    print('没有找到')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
